$:.unshift File.join(File.dirname(__FILE__),"..","lib")
require 'dice'



  def try_X_ones_on_first_roll(init_dice, number=6, number_of_dice = 6)
    d = Dice.new(init_dice,number_of_dice) 
    # let's verify some things just to be sure
    raise "dice were all not kept" unless d.to_hash == init_dice
    # just keep the one's
    d.roll([1])
    d.to_hash[1] >= number
  end

rolls = 10000 
success = 0
#init = {1 => 2, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0}
#1..rolls.times { success += 1 if try_X_ones_on_first_roll(init.dup, 3 , 6) }
#puts "Two one's on second roll success rate is " + (success / rolls.to_f).to_s

init = {1 => 2, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0}
success = 0
1..rolls.times { success += 1 if try_X_ones_on_first_roll(init.dup, 3, 6) }
puts "One one's on second roll success rate is " + (success / rolls.to_f).to_s

#init = {1 => 5, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0}
#success = 0
#1..rolls.times { success += 1 if try_X_ones_on_first_roll(init.dup, 6, 27) }
#puts "One one's on second roll success rate is " + (success / rolls.to_f).to_s
